﻿/****************************************************************************
*                                                                           *
* Copyright (c) Ionescu M. Marius. All rights reserved(2010).               *
*                                                                           *
****************************************************************************/

using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;

namespace CustomControlsNS
{
	/// <summary>
	/// Summary description for CustomButton
	/// </summary>
	public class UploadClasses : CompositeControl
	{
		public UploadClasses()
		{

		}

		public int controlNr
		{
			get { return ViewState["controlNr"] != null ? (int)ViewState["controlNr"] : 0; }
			set { ViewState["controlNr"] = value; }
		}

		public string smsSessionKey
		{
			get { return ViewState["smsSessionKey"] != null ? (string)ViewState["smsSessionKey"] : ""; }
			set { ViewState["smsSessionKey"] = value; }
		}

		protected override void CreateChildControls()
		{
			string strUploadHTML = "\n<center>";
			strUploadHTML += "\n<div style='width:400px'>";
			strUploadHTML += "\n<fieldset>";
			strUploadHTML += "\n<legend style='color: #225588'>" + Resources.DatabaseStrings.FileUpload + "</legend>";
			strUploadHTML += "\n<div id= 'divFrame" + this.ClientID + "'>";
			strUploadHTML += "\n<iframe id='ifrPhoto" + this.ClientID + "' onload='initPhotoUpload(\"" + this.ClientID + "\",\"" + this.controlNr + "\")' scrolling='no' frameborder='0' hidefocus='true'";
			strUploadHTML += "\nstyle='text-align:center;vertical-align:middle;border-style:none;margin:0px;width:100%;height:240px' src='ContentUpload.aspx?nr=" + this.controlNr.ToString() + "&smsSessionKey=" + smsSessionKey + "'></iframe>";
			strUploadHTML += "\n </div>";
			strUploadHTML += "\n<div id='divUploadMessage" + this.ClientID + "' style='padding-top:4px;display:none'></div>";
			strUploadHTML += "\n<div id='divUploadProgress" + this.ClientID + "' style='padding-top:4px;display:none'>";
			strUploadHTML += "\n<span style='font-size:smaller'>" + Resources.DatabaseStrings.Uploading + "</span>";
			strUploadHTML += "\n<div>";
			strUploadHTML += "\n<table border='0' cellpadding='0' cellspacing='2' style='width:100%'>";
			strUploadHTML += "\n<tbody>";
			strUploadHTML += "\n<tr>";
			strUploadHTML += "\n\n<td>";
			strUploadHTML += "\n\n<center>";
			strUploadHTML += "\n\n<img border='0' src='../Images/loader.gif' width='200' height='30'/>";
			strUploadHTML += "\n\n</center>";
			strUploadHTML += "\n\n</td>";
			strUploadHTML += "\n</tr>";
			strUploadHTML += "\n</tbody>";
			strUploadHTML += "\n</table>";
			strUploadHTML += "\n</div>";
			strUploadHTML += "\n</div>";
			strUploadHTML += "\n</fieldset>";
			strUploadHTML += "\n</div>";
			strUploadHTML += "\n</center>";
			strUploadHTML += "\n\n\n";

			Literal l = new Literal();
			l.Text = strUploadHTML;
			Controls.Add(l);
		}

	}

}
